﻿using System;
using RazakiBLL;
using RazakiBLL.Managers;

namespace RazakiSite.PagesForum
{
    public partial class MessageEdit : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            base.SetDefaultFormControls(null, UCMessageEdit.FindControl("TxtBSubject").ClientID);

            ConfigControls();

            //always run
            if (IsPostBack)
            {
                //after postback
                return;
            }
            //first time
        }

        protected override void ConfigControls()
        {
            string type = UtilitiesUI.GetQueryString<string>("messagetype");
            int typeId, permissionId;
            string permission = UtilitiesUI.GetQueryString<string>("messagepermission");
            UowRazaki uowRazaki = new UowRazaki();

            typeId = uowRazaki.MessageTypeRepository.GetByType(type).Id;
            permissionId = uowRazaki.MessagePermissionRepository.GetByPermission(permission).Id;

            UCMessageEdit.AllowSubmit = true;
            UCMessageEdit.TypeId = typeId;
            UCMessageEdit.PermissionId = permissionId;
        }
    }
}